home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
gui
/
gtlayout.lha
/
Source
/
gtlayout_lib.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-09-09
|
22KB
|
710 lines
/*
** GadTools layout toolkit
**
** Copyright © 1993-1998 by Olaf `Olsen' Barthel
** Freely distributable.
**
** :ts=4
*/
#ifndef _GTLAYOUT_GLOBAL_H
#include "gtlayout_global.h"
#endif
/*****************************************************************************/
#include <exec/execbase.h>
#include <exec/resident.h>
#include <dos/dos.h> /* For BPTR definition */
/*****************************************************************************/
#include "Assert.h"
#include "gtlayout.library_rev.h"
/*****************************************************************************/
/****** gtlayout.library/--version-- ******************************************
*
* NOTES
* This document describes gtlayout.library v5.12 or higher. Do not assume that
* previous library releases support the same features.
*
******************************************************************************
*
*/
/****** gtlayout.library/--background-- ******************************************
*
* NOTES
* 1. General information
*
* 1.1 Purpose
*
* The GUI code included in this archive helps to create user interfaces
* using gadtools.library with a minimum of effort. The code
* automatically takes care of the font to be used, making the user
* interface font independent. Localizing support is built right into
* the code, just install a callback hook and pass numeric IDs for the
* gadget labels: the code will invoke your hook in order to get the
* text required. Keystroke activation of gadgets is also taken care
* of, in fact the code will -- unless told not to do so -- assign keyboard
* shortcuts to the gadgets created all on its own. Every effort has been
* made to make the code reentrant, so it can be put into a shared library.
* If a user interface does not fit onto a screen provisions are made to
* choose a smaller font and to rescale the window contents until they fit.
* Last but not least the user interface code offers transparent extensions
* to the standard gadtools.library objects, such as LISTVIEW_KIND objects
* which respond to double-clicks or STRING_KIND objects which can be used
* to enter password text as they will not display the characters entered.
*
*
* 1.2 Distribution
*
* The code is *free*, you don't need to pay any money to use it, nor
* do you need to quote my name in the documentation, the program or
* anywhere else. You are allowed to make changes to the code, but if
* you stumble across any bugs or even know how to fix them, please
* let me know. It does not matter whether you intend to sell a program
* to use the code, use the code in shareware, gift-ware, freeware or
* etc.-ware programs: the code still remains royalty-free.
*
*
* 1.3 Caveats
*
* The code is pretty large, about 80K-100K bytes in size. Not all
* gadtools.library type objects are supported, notably
* GENERIC_KIND objects. The code is not as flexible as
* gadtools.library, so certain things which are easily done using
* gadtools.library may be pretty difficult or even impossible.
* The code is written entirely in `C' and requires SAS/C to
* compile. Some parts of the code are highly recursive; I haven't
* tested how much stack they might require in certain cases,
* but I recommend that you don't overuse the grouping feature.
* The data structures required to create and maintain the
* user interface are huge, a single window might require more
* than 4K-6K of memory. Proportional font support only works
* well starting with Kickstart v39 and up, v2.04 will probably
* not look quite that pretty.
*
*
* 2. Programming
*
* 2.1 Client libraries required for link library version
*
* You need to have SysBase and GadToolsBase initialized in order to make
* use of the code, i.e. your code has to do
* WaitPort()...GT_GetIMsg()...GT_ReplyIMsg all on its own. The code makes
* use of the memory pools introduced in exec.library v39, but calls the
* equivalent routines in amiga.lib. Note: as of this writing the pools
* code in amiga.lib v40.14 is broken, so you need to link with Mike
* Sinz' fixed pools.lib.
*
*
* 2.2 Invocation procedure
*
* The typical invocation procedure looks roughly like this:
*
* LT_Init(); // only for link library version
* :
* :
* LT_CreateHandleTags();
* LT_New();
* :
* :
* LT_New();
* LT_Build();
* LT_HandleInput();
* LT_DeleteHandle();
* :
* :
* LT_Exit(); // only for link library version
*
* You need to call LT_Init() only once in your program, it will initialize
* the libraries and global data structures required by the user interface
* code. When you are finished with the user interface and your program is
* about to exit you need to call LT_Exit() or memory will get lost.
* Note that LT_Init() is not protected against multiple invocations. If
* called repeatedly memory will get lost which can never be reclaimed.
* However, LT_Exit() is protected against multiple invocations, you can
* also call it before ever giving LT_Init() a call, but I doubt this
* would make much sense. If you are using the shared gtlayout.library
* no call to LT_Init()/LT_Exit() is necessary as these calls are already
* wrapped into the library opening code.
* Before you can actually start building a window layout a call to
* LT_CreateHandleTags() needs to be made. You need to pass in a pointer
* to the Screen your user interface window is to be opened on and,
* optionally, a few tags to control the look and performance of the
* interface. *Never* close the screen in question before calling
* LT_DeleteHandle() or nasty things will happen. For public screens
* the code will try to lock the screen in question. With the handle
* LT_CreateHandleTags() returned you can call LT_New() to build the
* user interface. When finished a call to LT_Build() will finally
* open a window and place the gadgets inside. A pointer to the
* Window created will be returned, ready to be used for the
* WaitPort()...GT_GetIMsg()...LT_HandleInput()...GT_ReplyIMsg()
* loop. When finished, a call to LT_DeleteHandle() will close the
* window and release all the memory associated with it. The design
* of the interface code is similar to the corresponding calls in
* gadtools.library, i.e. you don't need to worry about LT_New()
* failing to allocate memory for the objects required. When it comes
* to LT_Build() the code will know about any trouble which would
* show up during previous invocations of LT_New(). In essence,
* if LT_Build() returns NULL something is wrong.
*
*
* 2.3 Hierarchic grouping
*
* The basic building block of the user interface is a group, either
* a horizontal or a vertical group. Adding gadgets or other objects
* to a horizontal group will place them side by side from left to
* right. A vertical group causes objects to be place from top to
* bottom in one straight line. Groups help to arrange objects
* neatly stacked, centered and properly aligned with other
* members of the group.
*
* MUCHO IMPORTANTE: there is a bug lurking in the code which I never
* had the luck to find and fix. One would expect to create
* user interface structures like this:
*
* <group start>
* <button>
* <list>
* <group start>
* <slider>
* <text>
* <group end>
* <button>
* <group end>
*
* However, it is in fact not possible to mix gadgets and groups.
* Thus, the user interface structure would have to look like this:
*
* <group start>
* <group start>
* <button>
* <list>
* <group end>
* <group start>
* <slider>
* <text>
* <group end>
* <group start>
* <button>
* <group end>
* <group end>
*
* Or in other words: groups only mix with other groups.
*
* You build groups using three different object types. In this
* context `object type' refers to a specific numeric value the
* LT_New() routine knows which will cause it to add another leaf
* to the user interface structure tree. Here is an example:
*
* struct LayoutHandle *Handle;
*
* if(Handle = LT_CreateHandleTags(NULL,
* LAHN_AutoActivate,FALSE,
* TAG_DONE))
* {
* struct Window *Window;
*
* LT_New(Handle,
*